package com.itheima.reggie.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.io.Serializable;

@Data
@ApiModel("返回结果")
public class R<T> implements Serializable {
    @ApiModelProperty("返回编码")
    private int code;
    @ApiModelProperty("错误信息")
    private String msg;
    @ApiModelProperty("数据")
    private T data;
    public static <T> R<T> success(T object){
        R<T> r=new R<T>();
        r.code=1;
        r.data=object;
        return r;
    }
    public static <T> R<T> error(String msg){
        R<T> r=new R<T>();
        r.code=0;
        r.msg=msg;
        return r;
    }
}
